
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR RISC-V)

# 工具路径设置
set(TOOLCHAIN_DIR ${CMAKE_SOURCE_DIR}/toolchain/${PLATFORM}/${TOOLCHAIN})
# Linux 下工具链位置
set(TOOL_DIR ${TOOLCHAIN_DIR}/bin)

#设置工具链
set(CMAKE_C_COMPILER ${TOOL_DIR}/riscv64-unknown-elf-gcc)
# set(CMAKE_LINKER ${TOOL_DIR}/riscv64-unknown-elf-ld)
set(CMAKE_AR ${TOOL_DIR}/riscv64-unknown-elf-ar)

#设置编译参数
add_compile_options(
    -mtune=e906
    -O1
    -g3
    -Wall
    -fstrict-volatile-bitfields
    -ffunction-sections
    -fdata-sections
    -mno-relax
    -MMD
    -MP
)

# 添加解决编译问题
if(NOT CMAKE_SOURCE_DIR MATCHES "CMakeFiles/CMakeTmp")
    add_compile_options(
        -march=rv32imafcxtheade
        -mabi=ilp32f
    )
endif()

